#ifndef LONGKEY_COMMON_FILE_VER_H_
#define LONGKEY_COMMON_FILE_VER_H_

#include <Windows.h>
#include <atlstr.h>
#include "basictypes.h"

class FileVer
{
public:
	FileVer();
	~FileVer();

	// opens the version info for the specified file
	BOOL Open(const TCHAR *lpszModuleName);

	// Clean up
	void Close();

	// Query for a given value
	CString QueryValue(const TCHAR* lpszValueName) const;

	// Shortcuts for common values
	CString GetFileDescription() const {return QueryValue(_T("FileDescription"));}
	CString GetFileVersion() const     {return QueryValue(_T("FileVersion"));    }
	CString GetCompanyName() const     {return QueryValue(_T("CompanyName"));    }
	CString GetProductName() const     {return QueryValue(_T("ProductName"));    }
	CString GetProductVersion() const  {return QueryValue(_T("ProductVersion")); }

	// gets the FIXEDFILEINFO datastructure
	BOOL GetFixedInfo(VS_FIXEDFILEINFO& vsffi) const;   // NOLINT

	// returns a formated string representing the file and product versions
	// e.g. 2.4.124.34
	CString FormatFixedFileVersion() const;
	CString FormatFixedProductVersion() const;

	// Returns a ULONGLONG containing the version in DLL version format.
	ULONGLONG GetFileVersionAsULONGLONG() const;

	// gets the language ID
	LCID GetLanguageID() const         { return HIWORD(lang_charset_); }

private:
	// versioning data returned by GetFileVersionInfo
	byte*  file_ver_data_;

	// language charset
	DWORD   lang_charset_;

	DISALLOW_EVIL_CONSTRUCTORS(FileVer);
};

#endif	// LONGKEY_COMMON_FILE_VER_H_